import axios from 'axios'
axios.defaults.timeout = 3000
export default function (url, data = {}, type = 'get') {
  let pull = null
  return new Promise(function (resolve, reject) {
    if (type === 'get') {
      pull = axios.get(url, {
        params: data
      })
    } else if (type === 'post') {
      pull = axios.post(url, data)
    }
    pull.then(res => {
      resolve(res.data)
    }).catch(err => {
      reject(err)
    })
  })
}
